<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"   
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/default.xhtml">
   
   	<f:metadata>	   	
	   	<f:viewParam name="firstResult" value="#{serviceBuyerList.firstResult}"></f:viewParam>	
	   	<f:viewParam name="moduleName" value="采购方用户管理"></f:viewParam>
	   	<f:viewParam name="buyerName" value="#{serviceBuyerList.parameterValues['buyerName']}"></f:viewParam>
	   	<f:viewParam name="auditStatus" value="#{serviceBuyerList.parameterValues['auditStatus']}"></f:viewParam>
		<f:viewParam name="region" value="#{serviceBuyerList.region}"></f:viewParam>
   	</f:metadata>
   
   	<ui:define name="content">
   
		<h:form id="searchForm">
			<div style="height:50px;margin-left:10px">				
				<p:outputLabel value="采购方名称："></p:outputLabel>				
				<p:inputText value="#{serviceBuyerList.parameterValues['buyerName']}"></p:inputText>
				#{'    '}
				<p:outputLabel value="所属县区：" style="display: inline-block;margin-top: 5px;"></p:outputLabel>
				<p:selectOneMenu id="region"
								 value="#{serviceBuyerList.region}">
					<f:selectItem itemLabel="请选择" itemValue="#{null}"  />
					<f:selectItems value="#{codeDicUtils.getCodeDicList('所在地区')}" var="_codeDic" itemValue="#{_codeDic.codeValue}"
								   itemLabel="#{_codeDic.codeName}" />
				</p:selectOneMenu>
				#{'    '}
				<p:outputLabel value="审核状态："></p:outputLabel>				
				<p:selectOneMenu  value="#{serviceBuyerList.parameterValues['auditStatus']}">
								<f:selectItem itemLabel="请选择" itemValue="#{2}"  />
								<f:selectItem itemLabel="未审核" itemValue="#{null}" />
								<f:selectItem itemLabel="审核成功" itemValue="#{1}" />
								<f:selectItem itemLabel="审核失败" itemValue="#{0}" />
				</p:selectOneMenu>			
				<div class="actionButtons">
					<p:commandButton value="查询" ajax="false"   action="ServiceBuyerList.xhtml?faces-redirect=true&amp;includeViewParams=true&amp;firstResult=0" styleClass="blue-int"></p:commandButton>
					<p:button value="重置" outcome="ServiceBuyerList.xhtml"></p:button>
				</div>		
				<div class="clearbt"></div>
			</div>
			
			<p:panel id="searchResult">
				<f:facet name="header">采购方用户管理</f:facet>
				<p:dataTable value="#{serviceBuyerList.resultList}" var="_serviceBuyer">
					
					<p:column>
						<f:facet name="header">名称</f:facet>
						#{_serviceBuyer.cnname}
					</p:column>
					<p:column>
						<f:facet name="header">登录名</f:facet>
						#{_serviceBuyer.username}
					</p:column>
					<p:column width="60">
						<f:facet name="header">用户类型</f:facet>
						#{_serviceBuyer.buyerType}
					</p:column>
					
					<p:column width="60">
						<f:facet name="header">联系人</f:facet>
						#{_serviceBuyer.firstContactor}
					</p:column>
					
					<p:column width="100">
						<f:facet name="header">联系电话</f:facet>
						#{_serviceBuyer.firstContactorPhoneNumber}
					</p:column>
					
					<p:column>
						<f:facet name="header">联系地址</f:facet>
						#{_serviceBuyer.address}
					</p:column>
					<p:column>
						<f:facet name="header">所属县区</f:facet>
						#{codeDicUtils.getCodeDicValueKeyMap('所在地区')[_serviceBuyer.region]}
					</p:column>
					<p:column width="100">
						<f:facet name="header">注册日期</f:facet>
						<h:outputText value="#{_serviceBuyer.createDate}">
							<f:convertDateTime pattern="yyyy-MM-dd"/>
						</h:outputText>
					</p:column>
					<p:column style="text-align: center" width="120" >
						<f:facet name="header">操作</f:facet>
						<p:button value="审核" outcome="ServiceBuyerAudit.xhtml" rendered="#{empty _serviceBuyer.auditted}">							
							<f:param name="serviceBuyerId" value="#{_serviceBuyer.id}"></f:param>
						</p:button>
						<p:button value="查看" outcome="ServiceBuyerView.xhtml" rendered="#{not empty _serviceBuyer.auditted}">							
							<f:param name="serviceBuyerId" value="#{_serviceBuyer.id}"></f:param>
						</p:button>
						<p:button value="编辑" outcome="ServiceBuyerEdit.xhtml" >							
							<f:param name="serviceBuyerId" value="#{_serviceBuyer.id}"></f:param>
						</p:button>
						<p:button value="重置密码" outcome="ResetPassword.xhtml" rendered="false">
							<f:param name="userId" value="#{_serviceBuyer.id}"></f:param>
						</p:button>
						<p:button value="用户名修改" outcome="UserEdit.xhtml" rendered="#{request.isUserInRole('developer')}">
							<f:param name="userId" value="#{_serviceBuyer.id}"></f:param>
						</p:button>
					</p:column>
				</p:dataTable>
			</p:panel>
			
			<ui:include src="/WEB-INF/templates/manage/pagination.xhtml">
				<ui:param name="entityList" value="#{serviceBuyerList}" />
			</ui:include>
			
		</h:form>
      
   	</ui:define>
</ui:composition>
